package cn.sibu.plugin.authorize.activity;

import android.os.Bundle;

import cn.sibu.plugin.authorize.util.ActivityLifeCycle;
import core.dl.DLActivity;
import core.dl.internal.DLIntent;
import de.greenrobot.event.EventBus;

/**
 * Created by 刘红亮 on 2015/5/26 17:31
 */
public class BaseActivity extends DLActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityLifeCycle.addActivity(this);
    }

    @Override
    public void onDestroy() {
        //如果注册了EventBus，解除注册
        if(EventBus.getDefault().isRegistered(this)){
            EventBus.getDefault().unregister(this);
        }
        super.onDestroy();

        //移除生命周期控制
        ActivityLifeCycle.romoveActivity(this);
    }

    /**
     * 用于返回登录页
     */
    protected void backLoginUI() {
        DLIntent logIntent = new DLIntent(getPackageName(),
                LoginActivity.class);

        ActivityLifeCycle.removeAllActivity();
        startPluginActivity(logIntent);
        finish();

    }
}
